package com.neu.ui.notifications;

import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;

import com.android.volley.Request;
import com.google.gson.Gson;
import com.neu.bean.User;
import com.neu.util.VolleyUtil;

public class NotificationsViewModel extends ViewModel {

   public MutableLiveData<User> mUser;
   public Gson gson;
   public NotificationsViewModel(){
       mUser=new MutableLiveData<>();
       gson=new Gson();
   }

   public LiveData<User> getUser(){
       String url="/prod-api/api/common/user/getInfo";
       VolleyUtil.request(Request.Method.GET, url, null, new VolleyUtil.BackJson() {
           @Override
           public void success(String json) {
               User user=gson.fromJson(json,User.class);
               mUser.setValue(user);
           }
       });
       return mUser;
   }
}